package com.hqyj.repertory.controller;
import com.hqyj.repertory.model.InRepertory;
import frame.repertory.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;

@Controller
@RequestMapping("/repertoryController")
public class InRepertoryController extends BaseController {
    @RequestMapping("/in.do")
    public String inRepertoryList(HttpServletRequest request, HttpServletResponse response, Model model){
        ArrayList<InRepertory> inRepertory_list = inRepertoryService.queryAllInRepertory();
        model.addAttribute("inRepertory_list",inRepertory_list);
        return "/view/repertory/inRepertory/inRepertoryList";
    }
    @RequestMapping("/getInRepertory.do")
    public String queryInRepertoryById(HttpServletRequest request, HttpServletResponse response, Model model,String idStr){

        InRepertory inRepertory = inRepertoryService.queryInRepertoryById(Integer.parseInt(idStr));
        System.out.println(idStr);

        model.addAttribute("inRepertory",inRepertory);

        return "/view/repertory/inRepertory/updateInRepertory";
    }
    @RequestMapping("/updateInRepertory.do")
    public String updateInRepertory(HttpServletRequest request, HttpServletResponse response, Model model,InRepertory inRepertory){
        inRepertoryService.updateInRepertory(inRepertory);
        ArrayList<InRepertory> inRepertory_list = inRepertoryService.queryAllInRepertory();
        model.addAttribute("inRepertory_list",inRepertory_list);
        return "/view/repertory/inRepertory/inRepertoryList";
    }
}
